<template>
  <div class="method-box">
    <h6>均值算分法:</h6>
    <el-form ref="formRef" :model="form" label-width="auto" :rules="rules">
      <div>
        <span>评分点计算公式：有效供应商价格分的计算：</span>
        <div class="flex gap-1">
          （1）有效投标报价等于评标基准价的，报价得分=
          <el-form-item prop="scoreP">
            <el-input
              v-model.number="form.scoreP"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="P"
              @change="reflectChange"
            />
          </el-form-item>
          分。
        </div>
        <div class="flex gap-1">
          （2）如果投标人的有效投标报价＞评标基准价，则报价得分=P﹣|偏差率|×100×
          <el-form-item prop="scoreE1">
            <el-input
              v-model.number="form.scoreE1"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="E1"
              @change="reflectChange"
            />
          </el-form-item>
          ；
        </div>
        <div class="flex gap-1">
          （3）如果投标人的有效投标报价≤评标基准价，则报价得分=P﹣|偏差率|×100×
          <el-form-item prop="scoreE2">
            <el-input
              v-model.number="form.scoreE2"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="E2"
              @change="reflectChange"
            />
          </el-form-item>
          ；
        </div>
        <div class="flex gap-1">
          其中：E1是投标报价每高于评标基准价一个百分点的扣分值；E2是投标报价每低于评标基准价一个百分点的扣分值
        </div>
        <div class="flex gap-1">偏差率=100%×（评标基准价-投标人有效投标报价）/评标基准价</div>
        <div class="flex gap-1">
          基准价=扣除有效单位报价最高的
          <el-form-item prop="scoreN1">
            <el-input
              v-model.number="form.scoreN1"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="N1"
              @change="reflectChange"
            />
          </el-form-item>
          家，扣除有效单位报价最低的
          <el-form-item prop="scoreN2">
            <el-input
              v-model.number="form.scoreN2"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="N2"
              @change="reflectChange"
            />
          </el-form-item>
          家，后取剩余单位平均值×
          <el-form-item prop="scoreK">
            <el-input
              v-model.number="form.scoreK"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="K"
              @change="reflectChange"
            />
          </el-form-item>
          %；
        </div>
        <div class="flex gap-1">
          报价低于或等于采购预算价格的，为有效报价。超采购预算的报价为无效报价。无效报价的将不得分。
        </div>
      </div>
    </el-form>
  </div>
</template>
<script setup lang="ts">
const emit = defineEmits(['value-change'])
const reflectChange = () => {
  emit('value-change')
}

const rules = ref<any>({
  scoreP: [{ required: true, message: '请输入scoreP' }],
  scoreE1: [{ required: true, message: '请输入scoreE1' }],
  scoreE2: [{ required: true, message: '请输入scoreE2' }],
  scoreN1: [{ required: true, message: '请输入scoreN1' }],
  scoreN2: [{ required: true, message: '请输入scoreN2' }],
  scoreK: [{ required: true, message: '请输入scoreK' }]
})
const form = ref<any>({
  scoreP: '',
  scoreE1: '',
  scoreE2: '',
  scoreN1: '',
  scoreN2: '',
  scoreK: ''
})
const props = defineProps({
  formData: {
    type: Object,
    required: true
  },
  disabled: {
    type: Boolean,
    default: false
  }
})
const init = () => {
  form.value = props.formData
}
onMounted(() => {
  init()
})

const formRef = ref()
const submitForm = async () => {
  const res = await formRef.value.validate()
  return res
}
defineExpose({ form, submitForm })
</script>
<style scoped lang="scss" src="./text-common.scss"></style>
